package hikari.preferences.device_parameters;

import hikari.persistence.file.FileSection;
import hikari.persistence.propertieseditor.annotation.Property;
import java.io.IOException;
import org.swig.jirr.E_DRIVER_TYPE;

/**
 * @author sad
 */
public class DeviceParameters {

    @Property(id = "driver", caption = "Driver", help = "driver", editor = DevicePropertyEditor.class)
    private DriverType deviceType = DriverType.create(E_DRIVER_TYPE.EDT_OPENGL);
    @Property(id = "antialias", caption = "AntiAliasing", help = "antialiasing")
    private int antialias = 0;
    @Property(id = "bpp", caption = "Bits", help = "bpp")
    private int bits = 32;
    @Property(id = "dbuffer", caption = "Double Buffer", help = "doublebuffer")
    private boolean doubleBufferEnabled = true;
    @Property(id = "multthread", caption = "Multithreading", help = "multithreading")
    private boolean multithreading = false;
    @Property(id = "fullscr", caption = "Full Screen", help = "fullscreen")
    private boolean fullScreen = false;
    @Property(id = "srgb", caption = "Handle SRGB", help = "srgb")
    private boolean handleSRGB = false;
    @Property(id = "precfpu", caption = "Hight Precission FPU", help = "precissionFPU")
    private boolean hightPrecissionFpu = false;
    @Property(id = "stensil", caption = "Stensil Buffer", help = "stensil")
    private boolean stensilBuffer = false;
    @Property(id = "stereo", caption = "Stereo Buffer", help = "stereo")
    private boolean stereoBuffer = false;
    @Property(id = "vsync", caption = "VSync", help = "vsync")
    private boolean VSync = false;
    @Property(id = "perftimer", caption = "Use Performance Timer", help = "timer")
    private boolean usePerformanceTimer = false;
    @Property(id = "alpha", caption = "Use Alpha Channel", help = "alpha")
    private boolean useAlphaChannel = false;
    @Property(id = "width", caption = "Width", help = "width", min = "0", max = "5000")
    private int deviceWidth = 800;
    @Property(id = "height", caption = "Height", help = "height", min = "0", max = "5000")
    private int deviceHeight = 600;
    @Property(id = "zbuffer", caption = "ZBuffer bits", help = "zbuffer", min = "0", max = "64")
    private int zbufferBits = 16;

    public DriverType getDeviceType() {
        return deviceType;
    }

    public int getAntialias() {
        return antialias;
    }

    public int getBits() {
        return bits;
    }

    public boolean isDoubleBufferEnabled() {
        return doubleBufferEnabled;
    }

    public boolean isMultithreading() {
        return multithreading;
    }

    public boolean isFullScreen() {
        return fullScreen;
    }

    public boolean isHandleSRGB() {
        return handleSRGB;
    }

    public boolean isHightPrecissionFpu() {
        return hightPrecissionFpu;
    }

    public boolean isStensilBuffer() {
        return stensilBuffer;
    }

    public boolean isStereoBuffer() {
        return stereoBuffer;
    }

    public boolean isVSync() {
        return VSync;
    }

    public boolean isUsePerformanceTimer() {
        return usePerformanceTimer;
    }

    public boolean isUseAlphaChannel() {
        return useAlphaChannel;
    }

    public int getDeviceWidth() {
        return deviceWidth;
    }

    public int getDeviceHeight() {
        return deviceHeight;
    }

    public int getZbufferBits() {
        return zbufferBits;
    }

    
    
    public void save(FileSection section) throws IOException {
        section.writeLong("driver", deviceType.getDriverType());
        section.writeInt("antialias", antialias);
        section.writeInt("bpp", bits);
        section.writeBoolean("doubleBuffer", doubleBufferEnabled);
        section.writeBoolean("multThread", multithreading);
        section.writeBoolean("fullscreen", fullScreen);
        section.writeBoolean("srgb", handleSRGB);
        section.writeBoolean("precissionFpu", hightPrecissionFpu);
        section.writeBoolean("stensilBuffer", stensilBuffer);
        section.writeBoolean("stereoBuffer", stereoBuffer);
        section.writeBoolean("vsync", VSync);
        section.writeBoolean("perfTimer", usePerformanceTimer);
        section.writeBoolean("useAlpha", useAlphaChannel);
        section.writeInt("width", deviceWidth);
        section.writeInt("height", deviceHeight);
        section.writeInt("zBuffer", zbufferBits);
    }

    public void load(FileSection section) throws IOException {
        long driver = section.readLong(section.getChunk("driver"));
        deviceType = DriverType.create(E_DRIVER_TYPE.swigToEnum((int) driver));
        antialias = section.readInt(section.getChunk("antialias"));
        bits = section.readInt(section.getChunk("bpp"));
        deviceWidth = section.readInt(section.getChunk("width"));
        deviceHeight = section.readInt(section.getChunk("height"));
        zbufferBits = section.readInt(section.getChunk("zBuffer"));
        doubleBufferEnabled = section.readBoolean(section.getChunk("doubleBuffer"));
        multithreading = section.readBoolean(section.getChunk("multThread"));
        fullScreen = section.readBoolean(section.getChunk("fullscreen"));
        handleSRGB = section.readBoolean(section.getChunk("srgb"));
        hightPrecissionFpu = section.readBoolean(section.getChunk("precissionFpu"));
        stensilBuffer = section.readBoolean(section.getChunk("stensilBuffer"));
        stereoBuffer = section.readBoolean(section.getChunk("stereoBuffer"));
        VSync = section.readBoolean(section.getChunk("vsync"));
        usePerformanceTimer = section.readBoolean(section.getChunk("perfTimer"));
        useAlphaChannel = section.readBoolean(section.getChunk("useAlpha"));
        
    }
}
